/*
 *
 * @ProjectName:    my_umi_app
 * @Package:
 * @ClassName:      blog_tag_api
 * @Description:    Tag
 * @Author:         SuPeiSen
 * @CreateDate:     2021/2/13 2:18 下午
 * @UpdateDate:     2021/2/13 2:18 下午
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */

import { Requests } from '@/utils/requests';
import { AdTagItemType, BlogTagListType } from '@/type/blog/ad_type';
import { BlogApiPath } from '@/config/api_config';

/**
 * 获取所有的Tag
 */
export const BlogGetTagListApi = async function (): Promise<
  Array<AdTagItemType>
> {
  const model = await Requests.defaults.httpNo<Array<BlogTagListType>>(
    'get',
    BlogApiPath.blogTagList,
  );
  if (model.success) {
    const arr: Array<AdTagItemType> = [];
    model.data!.data.forEach((item) => {
      arr.push({
        id: item.id,
        color: item.tag_color,
        value: item.tag_name,
        onClick: () => {},
      });
    });
    return arr;
  }
  return [];
};
